<?php
/**
 *
 * @package 
 * @since 1.0
 * @todo 首页、列表页面、详细页
 */
 
class IndexAction extends AllAction{

	/**
	 * ------------------------------
	 * 权限判断
	 * ------------------------------
	 */
	function pan_quan_ajax($data){  //ajax判断
		$pan=in_array($data,$_SESSION['admin_quan']);
        if($pan){
			return true;
		}else{
			return false;
		}
	}
	function pan_quan($data){ //php跳转判断
		$pan=in_array($data,$_SESSION['admin_quan']);
        if(!$pan){
			$this->assign('jumpUrl', U('Index/index'));
			$this->error('您权限不足');
		}
	}
	//首页shishi
//	function indexshishi(){
//		$del = M("gg_lbimg")->where("id>0")->setField('webid','1');//1为发布
//        echo $del?'1':'0';
//		$this->display('index');
//	}
	 
	//首页
	function index(){
		$webid=$this->get_webid();
		//网站首页轮播配置
		$jiaodian = M('pz_jiaodian')->where("state=1 and webid=".$webid."")->order("xu asc,id desc")->limit(8)->select();
			$jiaodian=$this->get_lang_attr($jiaodian,"img_name");
			$jiaodian=$this->get_lang_attr($jiaodian,"img");
		$this->assign('jiaodian',$jiaodian);

		//网站首页视频
		$sy_shipin=M("sy_shipin")->where("state=1 and webid=".$webid."")->order("xu asc,id desc")->find();	
		$this->assign('sy_shipin',$sy_shipin);
		//网站首页精彩推荐
		$sy_tuijian=M("sy_tuijian")->where("state=1 and webid=".$webid."")->order("xu asc,id desc")->limit(10)->select();
		$this->assign('sy_tuijian',$sy_tuijian);
		//网站首页资讯
		$news=M("news")->where("state=1")->order("stime desc,id desc")->limit(5)->select();
		$this->assign('news',$news);
		//首页 节目单
		$sy_jiemudan=M('sy_jiemudan')->where("state=1")->order('xu asc,id desc')->limit(4)->select();
		$this->assign('sy_jiemudan', $sy_jiemudan);
		//萌星榜
		$mengbang=M('user')->where("state=1")->order('ctime desc,id desc')->limit(3)->select();
		$this->assign('mengbang', $mengbang);
		//其余两个榜
		$user_group=M('user_group')->where("state=1")->order("xu asc,ctime desc,id desc")->limit(2)->select();
		foreach($user_group as $k=>$v){
			$user_group[$k]['users']=M('user')->where("state=1 and groupid=".$v['id']."")->order("ctime desc,id desc")->limit(3)->select();
		}
		$this->assign('user_group', $user_group);
		
		//图吧榜
		$imgs_fenlei=M('imgs_fenlei')->where("state=1")->order("xu asc,ctime desc,id desc")->limit(7)->select();
		foreach($imgs_fenlei as $k=>$v){
			$imgs_fenlei[$k]['imgs']=M('imgs')->where("state=1 and fid=".$v['id']."")->order("ctime desc,id desc")->limit(8)->select();
		}
		$this->assign('imgs_fenlei', $imgs_fenlei);
		$this->assign('imgs_fenlei2', $imgs_fenlei);
		$this->assign('imgs_fenlei3', $imgs_fenlei);
		$this->assign('imgs_fenlei4', $imgs_fenlei);
				
		$this->display();
	}
	//排行榜
	function bang(){
		$webid=$this->get_webid();
		//网站首页轮播配置
		$jiaodian = M('pz_jiaodian')->where("state=1 and webid=".$webid."")->order("xu asc,id desc")->limit(8)->select();
			$jiaodian=$this->get_lang_attr($jiaodian,"img_name");
			$jiaodian=$this->get_lang_attr($jiaodian,"img");
		$this->assign('jiaodian',$jiaodian);

		//今日推荐
		$mengbang=M('user')->where("state=1")->order('ctime desc,id desc')->limit(8)->select();
		$this->assign('mengbang', $mengbang);
		$this->assign('mengbang2', $mengbang);
		//其余两个榜
		$user_group=M('user_group')->where("state=1")->order("xu asc,ctime desc,id desc")->select();
		foreach($user_group as $k=>$v){
			$user_group[$k]['users']=M('user')->where("state=1 and groupid=".$v['id']."")->order("ctime desc,id desc")->limit(11)->select();
		}
		$this->assign('user_group', $user_group);
		$this->assign('user_group2', $user_group);
						
		$this->display();
	}
	//将 语言ID 存到cookie
	function cookie_lang(){
		$langid=$_POST['langid'];
		setcookie("langid",$langid, time()+3600*24*365);
		echo $cc=$langid;
		
	}
	//将 语言ID 存到cookie
	function yulan_cookie_lang(){
		$langid=$_GET['langid'];
		setcookie("langid",$langid, time()+3600*24*365);
		$this->redirect(U('Index/index'));
	}
	//将 所在城市ID 存到cookie
	function cookie_sz_area_id(){
		$sz_area_id=$_POST['sz_area_id'];
		setcookie("sz_area_id",$sz_area_id, time()+3600*24*365);
		echo $cc=$sz_area_id;
		
	}
	function m_area(){
		$menuid=$_GET['mid'];
		$ss_menuid=",".$menuid.",";
		$_SESSION['menuid']=$menuid;
		//选择商家所在城市，存cookie
		$sz_area_id=$_COOKIE['sz_area_id'];		
		
		$dh_menu=M('pz_menu')->find($menuid);
			//各字段 各语言
			$dh_menu=$this->get_lang($dh_menu,"name");
		
		//获取作家组 用户id
		$zuojiaids=D("admin")->where("groupid=5 and state=1")->select();
		foreach($zuojiaids as $k=>$v){
			$zuojiaid_str.=$v['id'].",";
		}
		$zuojiaid_str=rtrim($zuojiaid_str,",");
		//获取24小时前时间
		$yestday=time()-3600*24;

		if($menuid==28 || $menuid==13 ){
			$article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and area_id IS NOT NULL  and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%' and area_id IS NOT NULL ")->order('stime desc,id desc')->select();
			foreach($article as $k=>$v){
					$areaid_str=trim($areaid_str,",").",".trim($v['area_id'],",");
			}
			$areaid_str=trim($areaid_str,",");

			$area=M('pz_area')->where("id in (".$areaid_str.") and state=1")->order('xu asc,id asc')->select();
			foreach($area as $k=>$v){
				$area[$k]['art']=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and area_id like '%".','.$v['id'].','."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%' and area_id like '%".','.$v['id'].','."%' ")->order('stime desc,id desc')->limit("0,4")->select();
				$area[$k]['art'][0]['zhutu']=$this->get_thumb2($area[$k]['art'][0]['zhutu']);
				$area[$k]['url']=$area[$k]['art'][0]['zhutu'];
			}
			
			//获取编辑组 用户id
			$bianjiids=D("admin")->where("groupid<=3 and state=1")->select();
			foreach($bianjiids as $k=>$v){
				$bianjiid_str.=$v['id'].",";
			}
			$bianjiid_str=rtrim($bianjiid_str,",");
			//Must Read 编辑推荐
			$must_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid IN (".$bianjiid_str.") ")->order('stime desc,id desc')->limit(8)->select();
				$must_article=$this->get_lang_attr($must_article,"name");
			$this->assign('must_article', $must_article);

			//最多浏览
			$hot_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('readss desc,id desc')->limit(8)->select();
				$hot_article=$this->get_lang_attr($hot_article,"name");
			$this->assign('hot_article', $hot_article);
			
			//最新报导
			$new_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('stime desc,id desc')->limit(8)->select();
				$new_article=$this->get_lang_attr($new_article,"name");
			$this->assign('new_article', $new_article);
			
			//最多人收藏
			$fol_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'   ")->order('follows desc,id desc')->limit(8)->select();
				$fol_article=$this->get_lang_attr($fol_article,"name");
			$this->assign('fol_article', $fol_article);

			$this->assign('area', $area);
			$this->assign('dh_menu', $dh_menu);
			$this->display();
		}else{
		

			import("@.ORG.Page");
			
			if($sz_area_id==0 || $sz_area_id==""){
				$count	= M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->count();
				$Page	= New Page($count,30);
				$show	= $Page->show();
				//$article=M('article')->where("state=1 and menuid like '%".$menuid."%'")->order('stime desc,id desc')->select();
				$article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('stime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			
					$article=$this->get_lang_attr($article,"zhutu");
					$article=$this->get_lang_attr($article,"zhutuly");
					$article=$this->get_lang_attr($article,"name");
					$article=$this->get_lang_attr($article,"namesm");
				
			}
			if($sz_area_id>0){
				$article=array();
				$shop=M('shop')->where("state=1 and ".$sz_area_id." IN (areas_id) ")->order('ctime desc,id desc')->select();
				foreach($shop as $k=>$v){
					if($v["id"]){
						$article_ids_arrs=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and shopid like '%".','.$v['id'].','."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%' and shopid like '%".','.$v['id'].','."%' ")->order('stime desc,id desc')->select();
						foreach($article_ids_arrs as $kk=>$vv){
							$article_ids_arr[]=$vv['id'];
						}
					}
				}
				$article_ids=implode(",",$article_ids_arr);
				$count	= M('article')->where("id in (".$article_ids.") ")->count();
				$Page	= New Page($count,30);
				$show	= $Page->show();
				$article=M('article')->where("id in (".$article_ids.") ")->order('stime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
					$article=$this->get_lang_attr($article,"zhutu");
					$article=$this->get_lang_attr($article,"zhutuly");
					$article=$this->get_lang_attr($article,"name");
					$article=$this->get_lang_attr($article,"namesm");
				
				$sz_area=M('pz_areas')->find($sz_area_id);
					$sz_area=$this->get_lang($sz_area,"name");
				$this->assign('sz_area', $sz_area);

			}
			
			//获取作者
			foreach($article as $k=>$v){
				$art_user[$k]=M('admin')->find($v['uid']);
				$art_user[$k]=$this->get_lang($art_user[$k],"adm_name");
				$art_user[$k]=$this->get_lang($art_user[$k],"nicheng");
				if($art_user[$k]['nicheng']){
					$article[$k]['user_nc']=$art_user[$k]['nicheng'];
				}else{
					$article[$k]['user_nc']=$art_user[$k]['adm_name'];
				}
				if($article[$k]['user_nc']=="admin"){
					$article[$k]['user_nc']="Trinity";
				}
			
			}


			//获取编辑组 用户id
			$bianjiids=D("admin")->where("groupid<=3 and state=1")->select();
			foreach($bianjiids as $k=>$v){
				$bianjiid_str.=$v['id'].",";
			}
			$bianjiid_str=rtrim($bianjiid_str,",");
			//Must Read 编辑推荐
			$must_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid IN (".$bianjiid_str.") ")->order('stime desc,id desc')->limit(8)->select();
				$must_article=$this->get_lang_attr($must_article,"name");
			$this->assign('must_article', $must_article);

			//最多浏览
			$hot_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('readss desc,id desc')->limit(8)->select();
				$hot_article=$this->get_lang_attr($hot_article,"name");
			$this->assign('hot_article', $hot_article);
			
			//最新报导
			$new_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('stime desc,id desc')->limit(8)->select();
				$new_article=$this->get_lang_attr($new_article,"name");
			$this->assign('new_article', $new_article);
			
			//最多人收藏
			$fol_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'   ")->order('follows desc,id desc')->limit(8)->select();
				$fol_article=$this->get_lang_attr($fol_article,"name");
			$this->assign('fol_article', $fol_article);

			$this->assign('dh_menu', $dh_menu);
			foreach($article as $k=>$v){
				//获取缩略图
				$article[$k]['zhutu']=$this->get_thumb2($v['zhutu']);
			}
			$this->assign('article', $article);
			$this->assign('page', $show);
			$this->display("articles");
		}

	}
	function m_area_art(){
		//获取作家组 用户id
		$zuojiaids=D("admin")->where("groupid=5 and state=1")->select();
		foreach($zuojiaids as $k=>$v){
			$zuojiaid_str.=$v['id'].",";
		}
		$zuojiaid_str=rtrim($zuojiaid_str,",");
		//获取24小时前时间
		$yestday=time()-3600*24;

		$menuid=$_GET['mid'];
		$_SESSION['menuid']=$menuid;
		$areaid=$_GET['aid'];
		$ss_menuid=",".$menuid.",";
		
		if($menuid){
			$dh_menu=M('pz_menu')->find($menuid);
		}
		$dh_area=M('pz_area')->find($areaid);
		//各字段 各语言
			$dh_menu=$this->get_lang($dh_menu,"name");
			$dh_area=$this->get_lang($dh_area,"name");
		if(!$menuid){
			$article=M('article')->where("state=1 and menuid like '%,28,%' and area_id like '%".','.$areaid.','."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%,28,%' and area_id like '%".','.$areaid.','."%' ")->order('stime desc,id desc')->select();
		}else{
			$article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%'  and area_id like '%".','.$areaid.','."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  and area_id like '%".','.$areaid.','."%' ")->order('stime desc,id desc')->select();
		}
			//获取作者
			foreach($article as $k=>$v){
				$art_user[$k]=M('admin')->find($v['uid']);
				$art_user[$k]=$this->get_lang($art_user[$k],"adm_name");
				$art_user[$k]=$this->get_lang($art_user[$k],"nicheng");
				if($art_user[$k]['nicheng']){
					$article[$k]['user_nc']=$art_user[$k]['nicheng'];
				}else{
					$article[$k]['user_nc']=$art_user[$k]['adm_name'];
				}
				if($article[$k]['user_nc']=="admin"){
					$article[$k]['user_nc']="Trinity";
				}
			
			}

			$article=$this->get_lang_attr($article,"zhutu");
			$article=$this->get_lang_attr($article,"zhutuly");
			$article=$this->get_lang_attr($article,"name");
			$article=$this->get_lang_attr($article,"namesm");
		//var_dump($dh_area);	
		$this->assign('dh_menu', $dh_menu);
		$this->assign('dh_area', $dh_area);
		$this->assign('article', $article);

		//获取编辑组 用户id
		$bianjiids=D("admin")->where("groupid<=3 and state=1")->select();
		foreach($bianjiids as $k=>$v){
			$bianjiid_str.=$v['id'].",";
		}
		$bianjiid_str=rtrim($bianjiid_str,",");
		//Must Read 编辑推荐
		$must_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid IN (".$bianjiid_str.") ")->order('stime desc,id desc')->limit(8)->select();
			$must_article=$this->get_lang_attr($must_article,"name");
		$this->assign('must_article', $must_article);

		//最多浏览
		$hot_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('readss desc,id desc')->limit(8)->select();
			$hot_article=$this->get_lang_attr($hot_article,"name");
		$this->assign('hot_article', $hot_article);
		
		//最新报导
		$new_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('stime desc,id desc')->limit(8)->select();
			$new_article=$this->get_lang_attr($new_article,"name");
		$this->assign('new_article', $new_article);
		
		//最多人收藏
		$fol_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'   ")->order('follows desc,id desc')->limit(8)->select();
			$fol_article=$this->get_lang_attr($fol_article,"name");
		$this->assign('fol_article', $fol_article);

		$this->display();
	}
	//文章 资讯
	function news_show(){
		$newsid=$_GET['nid'];
		$news=M('news')->find($newsid);
		foreach($news as $k=>$v){
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$news[$k]=stripslashes($v); 
			}
		}
		//权限判断
//		if($news['state']!=1){
//			if($news['uid']==$_SESSION['uid']){
//				$pan=$this->pan_quan(13);//判断预览自己权限
//			}else{
//				$pan=$this->pan_quan(14);//判断预览别人权限
//			}
//		}else{
//			if(in_array($news['uid'],$zuojiaid_array) && $news['stime']>$yestday){
//				if($news['uid']==$_SESSION['uid']){
//					$pan=$this->pan_quan(13);//判断预览自己权限
//				}else{
//					$pan=$this->pan_quan(14);//判断预览别人权限
//				}
//			}
//		}
		$art_user=M('admin')->find($news['uid']);
		$art_user=$this->get_lang($art_user,"adm_name");
		$art_user=$this->get_lang($art_user,"nicheng");
		if($art_user['nicheng']){
			$news['user_nc']=$art_user['nicheng'];
		}else{
			$news['user_nc']=$art_user['adm_name'];
		}
		if($news['user_nc']=="admin"){
			$news['user_nc']="Trinity";
		}
			$news=$this->get_lang($news,"name");
			$news=$this->get_lang($news,"namesm");
			$news=$this->get_lang($news,"content");
			$news=$this->get_lang($news,"zhutu");
		
		//首页 节目单
		$sy_jiemudan=M('sy_jiemudan')->where("state=1")->order('xu asc,id desc')->limit(4)->select();
		$this->assign('sy_jiemudan', $sy_jiemudan);

		//最新资讯
		$new_news=M('news')->where("state=1")->order('stime desc,id desc')->limit(6)->select();
		$this->assign('new_news', $new_news);
		
		$this->assign('news', $news);
		
		
		//文章关注
		$art_gz_zt=M('news_gz')->where("artid=".$news['id']." and uid=".$_SESSION['uid']." and state=1")->find();
		$this->assign('art_gz_zt', $art_gz_zt);
		
				
		M('news')->where("id=".$newsid."")->setInc('readss');
		$this->display();
	}
	//文章 资讯
	function news(){
		import("@.ORG.Page");
		$count	= M('news')->where("state=1")->count();
		$Page	= New Page($count,10);
		$show	= $Page->show();
		$news=M('news')->where("state=1")->order('stime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		foreach($news as $k=>$v){
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$news[$k]['content']=stripslashes($v['content']); 
				$news[$k]['name']=stripslashes($v['name']); 
				$news[$k]['namesm']=stripslashes($v['namesm']); 
			}
		}
		$this->assign('news', $news);
		$this->assign('page', $show);

//		//权限判断
//		if($news['state']!=1){
//			if($news['uid']==$_SESSION['uid']){
//				$pan=$this->pan_quan(13);//判断预览自己权限
//			}else{
//				$pan=$this->pan_quan(14);//判断预览别人权限
//			}
//		}else{
//			if(in_array($news['uid'],$zuojiaid_array) && $news['stime']>$yestday){
//				if($news['uid']==$_SESSION['uid']){
//					$pan=$this->pan_quan(13);//判断预览自己权限
//				}else{
//					$pan=$this->pan_quan(14);//判断预览别人权限
//				}
//			}
//		}
		$art_user=M('admin')->find($news['uid']);
		$art_user=$this->get_lang($art_user,"adm_name");
		$art_user=$this->get_lang($art_user,"nicheng");
		if($art_user['nicheng']){
			$news['user_nc']=$art_user['nicheng'];
		}else{
			$news['user_nc']=$art_user['adm_name'];
		}
		if($news['user_nc']=="admin"){
			$news['user_nc']="Trinity";
		}
			$news=$this->get_lang($news,"name");
			$news=$this->get_lang($news,"namesm");
			$news=$this->get_lang($news,"content");
			$news=$this->get_lang($news,"zhutu");
		
		//首页 节目单
		$sy_jiemudan=M('sy_jiemudan')->where("state=1")->order('xu asc,id desc')->limit(4)->select();
		$this->assign('sy_jiemudan', $sy_jiemudan);

		//最新资讯
		$new_news=M('news')->where("state=1")->order('stime desc,id desc')->limit(6)->select();
		$this->assign('new_news', $new_news);
		
		
		
		//文章关注
		$art_gz_zt=M('news_gz')->where("artid=".$news['id']." and uid=".$_SESSION['uid']." and state=1")->find();
		$this->assign('art_gz_zt', $art_gz_zt);
		
				
		M('news')->where("id=".$newsid."")->setInc('readss');
		$this->display();
	}
	//文章 资讯
	function videos_show(){
		$videosid=$_GET['nid'];
		$videos=M('videos')->find($videosid);
		foreach($videos as $k=>$v){
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$videos[$k]=stripslashes($v); 
			}
		}
//		//权限判断
//		if($videos['state']!=1){
//			if($videos['uid']==$_SESSION['uid']){
//				$pan=$this->pan_quan(13);//判断预览自己权限
//			}else{
//				$pan=$this->pan_quan(14);//判断预览别人权限
//			}
//		}else{
//			if(in_array($videos['uid'],$zuojiaid_array) && $videos['stime']>$yestday){
//				if($videos['uid']==$_SESSION['uid']){
//					$pan=$this->pan_quan(13);//判断预览自己权限
//				}else{
//					$pan=$this->pan_quan(14);//判断预览别人权限
//				}
//			}
//		}
		$art_user=M('admin')->find($videos['uid']);
		$art_user=$this->get_lang($art_user,"adm_name");
		$art_user=$this->get_lang($art_user,"nicheng");
		if($art_user['nicheng']){
			$videos['user_nc']=$art_user['nicheng'];
		}else{
			$videos['user_nc']=$art_user['adm_name'];
		}
		if($videos['user_nc']=="admin"){
			$videos['user_nc']="Trinity";
		}
			$videos=$this->get_lang($videos,"name");
			$videos=$this->get_lang($videos,"namesm");
			$videos=$this->get_lang($videos,"content");
			$videos=$this->get_lang($videos,"zhutu");
		
		//首页 节目单
		$sy_jiemudan=M('sy_jiemudan')->where("state=1")->order('xu asc,id desc')->limit(4)->select();
		$this->assign('sy_jiemudan', $sy_jiemudan);

		//最新资讯
		$new_news=M('news')->where("state=1")->order('stime desc,id desc')->limit(6)->select();
		$this->assign('new_news', $new_news);
		
		$this->assign('videos', $videos);
				
		M('videos')->where("id=".$videosid."")->setInc('readss');
		$this->display();
	}
	//文章 视频
	function videos(){
		import("@.ORG.Page");
		$count	= M('videos')->where("state=1")->count();
		$Page	= New Page($count,10);
		$show	= $Page->show();
		$videos=M('videos')->where("state=1")->order('stime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		foreach($videos as $k=>$v){
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$videos[$k]['content']=stripslashes($v['content']); 
				$videos[$k]['name']=stripslashes($v['name']); 
				$videos[$k]['namesm']=stripslashes($v['namesm']); 
			}
		}
		$this->assign('videos', $videos);
		$this->assign('page', $show);

//		//权限判断
//		if($videos['state']!=1){
//			if($videos['uid']==$_SESSION['uid']){
//				$pan=$this->pan_quan(13);//判断预览自己权限
//			}else{
//				$pan=$this->pan_quan(14);//判断预览别人权限
//			}
//		}else{
//			if(in_array($videos['uid'],$zuojiaid_array) && $videos['stime']>$yestday){
//				if($videos['uid']==$_SESSION['uid']){
//					$pan=$this->pan_quan(13);//判断预览自己权限
//				}else{
//					$pan=$this->pan_quan(14);//判断预览别人权限
//				}
//			}
//		}
		$art_user=M('admin')->find($videos['uid']);
		$art_user=$this->get_lang($art_user,"adm_name");
		$art_user=$this->get_lang($art_user,"nicheng");
		if($art_user['nicheng']){
			$videos['user_nc']=$art_user['nicheng'];
		}else{
			$videos['user_nc']=$art_user['adm_name'];
		}
		if($videos['user_nc']=="admin"){
			$videos['user_nc']="Trinity";
		}
			$videos=$this->get_lang($videos,"name");
			$videos=$this->get_lang($videos,"namesm");
			$videos=$this->get_lang($videos,"content");
			$videos=$this->get_lang($videos,"zhutu");
		
		//首页 节目单
		$sy_jiemudan=M('sy_jiemudan')->where("state=1")->order('xu asc,id desc')->limit(4)->select();
		$this->assign('sy_jiemudan', $sy_jiemudan);

		//最新资讯
		$new_news=M('news')->where("state=1")->order('stime desc,id desc')->limit(6)->select();
		$this->assign('new_news', $new_news);
		
		
				
		M('videos')->where("id=".$videosid."")->setInc('readss');
		$this->display();
	}
	//图吧
	function imgs(){
		$webid=$this->get_webid();
		//网站首页轮播配置
		$jiaodian = M('pz_jiaodian')->where("state=1 and webid=".$webid."")->order("xu asc,id desc")->limit(8)->select();
			$jiaodian=$this->get_lang_attr($jiaodian,"img_name");
			$jiaodian=$this->get_lang_attr($jiaodian,"img");
		$this->assign('jiaodian',$jiaodian);
		if(!empty($_GET['gid'])){
			$imgs_fenlei=M('imgs_fenlei')->where("state=1 and id=".$_GET['gid']."")->order("xu asc,ctime desc,id desc")->select();
			foreach($imgs_fenlei as $k=>$v){
				import("@.ORG.Page");
				$count	= M('imgs')->where("state=1 and fid=".$v['id']."")->count();
				$Page	= New Page($count,15);
				$show	= $Page->show();
				$list = M('imgs')->where("state=1 and fid=".$v['id']."")->order("ctime desc,id desc")->limit($Page->firstRow.','.$Page->listRows)
									 ->select();

				$imgs_fenlei[$k]['imgs']=$list;
				$this->assign('list', $list);
				$this->assign('page', $show);
			}
		}else{
			$imgs_fenlei=M('imgs_fenlei')->where("state=1")->order("xu asc,ctime desc,id desc")->select();
			foreach($imgs_fenlei as $k=>$v){
				$imgs_fenlei[$k]['imgs']=M('imgs')->where("state=1 and fid=".$v['id']."")->order("ctime desc,id desc")->limit(8)->select();
			}
		}
		$this->assign('imgs_fenlei',$imgs_fenlei);
		$this->display();
	}
	//文章 相册
	function photos_show(){
		$photo_filesid=$_GET['id'];
		$photo_files=M('article_photo_files')->find($photo_filesid);
		foreach($photo_files as $k=>$v){
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$photo_files[$k]=stripslashes($v); 
			}
		}
		$user=M('user')->find($photo_files['suid']);
		$photo_files['suname']=$user['name'];
//		//权限判断
//		if($videos['state']!=1){
//			if($videos['uid']==$_SESSION['uid']){
//				$pan=$this->pan_quan(13);//判断预览自己权限
//			}else{
//				$pan=$this->pan_quan(14);//判断预览别人权限
//			}
//		}else{
//			if(in_array($videos['uid'],$zuojiaid_array) && $videos['stime']>$yestday){
//				if($videos['uid']==$_SESSION['uid']){
//					$pan=$this->pan_quan(13);//判断预览自己权限
//				}else{
//					$pan=$this->pan_quan(14);//判断预览别人权限
//				}
//			}
//		}
			$videos=$this->get_lang($videos,"name");
		
		//首页 节目单
		$sy_jiemudan=M('sy_jiemudan')->where("state=1")->order('xu asc,id desc')->limit(4)->select();
		$this->assign('sy_jiemudan', $sy_jiemudan);

		//最新资讯
		$new_news=M('news')->where("state=1")->order('stime desc,id desc')->limit(6)->select();
		$this->assign('new_news', $new_news);
		
		$this->assign('photo_files', $photo_files);
		$photos=M('article_photo')->where("fid=".$photo_files['id']." and state=1")->order('ctime desc,id desc')->select();
		$this->assign('photos', $photos);
				
		M('article_photo_files')->where("id=".$photo_filesid."")->setInc('readss');
		$this->display();
	}
	//文章 报导
	function article(){
		//获取作家组 用户id
		$zuojiaids=D("admin")->where("groupid=5 and state=1")->select();
		foreach($zuojiaids as $k=>$v){
			$zuojiaid_str.=$v['id'].",";
			$zuojiaid_array[]=$v['id'];
		}
		$zuojiaid_str=rtrim($zuojiaid_str,",");
		//var_dump($zuojiaid_array);
		//获取24小时前时间
		$yestday=time()-3600*24;

		$areaid=$_GET['aid'];
		$articleid=$_GET['arid'];

		$sz_area_id=$_COOKIE['sz_area_id'];
		
		if($areaid>0){
			$dh_area=M('pz_area')->find($areaid);
				$dh_area=$this->get_lang($dh_area,"name");
			$this->assign('dh_area', $dh_area);
		}
		
		if($sz_area_id>0){
			$sz_area=M('pz_areas')->find($sz_area_id);
				$sz_area=$this->get_lang($sz_area,"name");
			$this->assign('sz_area', $sz_area);
		}
		
		$article=M('article')->find($articleid);
		foreach($article as $k=>$v){
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$article[$k]=stripslashes($v); 
			}
		}
		
		if($_GET['mid']>0){
			$menuid=$_GET['mid'];
		}else{
			$menuid_str=trim($article['menuid'],",");
			$menuid_attr=explode(",",$menuid_str);
			$menuid=$menuid_attr[0];
		}
		if($menuid>0){
			$_SESSION['menuid']=$menuid;
			$ss_menuid=",".$menuid.",";
			$dh_menu=M('pz_menu')->find($menuid);
				$dh_menu=$this->get_lang($dh_menu,"name");
			$this->assign('dh_menu', $dh_menu);
		}
//		//权限判断
//		if($article['state']!=1){
//			if($article['uid']==$_SESSION['uid']){
//				$pan=$this->pan_quan(13);//判断预览自己权限
//			}else{
//				$pan=$this->pan_quan(14);//判断预览别人权限
//			}
//		}else{
//			if(in_array($article['uid'],$zuojiaid_array) && $article['stime']>$yestday){
//				if($article['uid']==$_SESSION['uid']){
//					$pan=$this->pan_quan(13);//判断预览自己权限
//				}else{
//					$pan=$this->pan_quan(14);//判断预览别人权限
//				}
//			}
//		}
		$art_user=M('admin')->find($article['uid']);
		$art_user=$this->get_lang($art_user,"adm_name");
		$art_user=$this->get_lang($art_user,"nicheng");
		if($art_user['nicheng']){
			$article['user_nc']=$art_user['nicheng'];
		}else{
			$article['user_nc']=$art_user['adm_name'];
		}
		if($article['user_nc']=="admin"){
			$article['user_nc']="Trinity";
		}
//		$info = @getimagesize('.'.$article['zhutu']);
//		var_dump((int)($info[0]*0.15));
//		var_dump($article['zhutu']);
			$article=$this->get_lang($article,"name");
			$article=$this->get_lang($article,"namesm");
			$article=$this->get_lang($article,"content");
			$article=$this->get_lang($article,"zhutu");
			$article=$this->get_lang($article,"zhutuly");
//			$article=$this->get_lang($article,"areainf");
//			$article=$this->get_lang($article,"remark");
//			$article=$this->get_lang($article,"qa");
//			$article=$this->get_lang($article,"service");
//			$article=$this->get_lang($article,"service_out");
//			$article=$this->get_lang($article,"service_pack");
		
		$xiangce=M('article_photo_files')->where("state=1 and aid=".$articleid."")->order('xu asc,ctime desc,id desc')->select();
			$xiangce=$this->get_lang_attr($xiangce,"name");
			$xiangce=$this->get_lang_attr($xiangce,"url");
			$xiangce=$this->get_lang_attr($xiangce,"urlly");
			$xiangce=$this->get_lang_attr($xiangce,"intro");
		$this->assign('xiangce', $xiangce);
		
		$shipin=M('article_video')->where("state=1 and aid=".$articleid."")->order('xu asc,ctime desc,id desc')->select();
			$shipin=$this->get_lang_attr($shipin,"name");
			$shipin=$this->get_lang_attr($shipin,"url");
			$shipin=$this->get_lang_attr($shipin,"urlly");
			$shipin=$this->get_lang_attr($shipin,"intro");
		$this->assign('shipin', $shipin);
		
		$article['shopid']=trim($article['shopid'],",");
		$shop=M('shop')->where("state=1 and id in (".$article['shopid'].")")->order('ctime desc,id desc')->select();
			$shop=$this->get_lang_attr($shop,"name");
		$this->assign('shop', $shop);

		if(!$menuid){
			$menuid=$article['menuid'];
		}
		if(!$menuid){
			$menuid=$_SESSION['menuid'];
		}
		
		//获取编辑组 用户id
		$bianjiids=D("admin")->where("groupid<=3 and state=1")->select();
		foreach($bianjiids as $k=>$v){
			$bianjiid_str.=$v['id'].",";
		}
		$bianjiid_str=rtrim($bianjiid_str,",");
		//Must Read 编辑推荐
		$must_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid IN (".$bianjiid_str.") ")->order('stime desc,id desc')->limit(8)->select();
			$must_article=$this->get_lang_attr($must_article,"name");
		$this->assign('must_article', $must_article);

		//最多浏览
		$hot_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('readss desc,id desc')->limit(8)->select();
			$hot_article=$this->get_lang_attr($hot_article,"name");
		$this->assign('hot_article', $hot_article);
		
		//最新报导
		$new_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('stime desc,id desc')->limit(8)->select();
			$new_article=$this->get_lang_attr($new_article,"name");
		$this->assign('new_article', $new_article);
		
		//最多人收藏
		$fol_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'   ")->order('follows desc,id desc')->limit(8)->select();
			$fol_article=$this->get_lang_attr($fol_article,"name");
		$this->assign('fol_article', $fol_article);

		$this->assign('article', $article);
		
		//文章 评论
		import("@.ORG.Page");
		$count	= M('article_pl')->where("artid=".$article['id']." and plid=0 and state=1")->count();
		$Page	= New Page($count,30);
		$show	= $Page->show();
		$art_pl=M('article_pl')->where("artid=".$article['id']." and plid=0 and state=1")->order('ctime asc,id asc')->limit($Page->firstRow.','.$Page->listRows)->select();
		foreach($art_pl as $k=>$v){
			$zuozhe=M('admin')->find($v['uid']);
			if(!empty($zuozhe['nicheng'])){
				$art_pl[$k]['zuozhe_nc']=$zuozhe['nicheng'];
			}else{
				$art_pl[$k]['zuozhe_nc']=$zuozhe['adm_name'];
			}
			$art_pl[$k]['hf']=M('article_pl')->where("artid=".$article['id']." and plid=".$v['id']." and state=1")->order('ctime asc,id asc')->select();
			foreach($art_pl[$k]['hf'] as $kk=>$vv){
				
				$zuozhe_hf=M('admin')->find($vv['uid']);
				if(!empty($zuozhe_hf['nicheng'])){
					$art_pl[$k]['hf'][$kk]['zuozhe_nc']=$zuozhe_hf['nicheng'];
				}else{
					$art_pl[$k]['hf'][$kk]['zuozhe_nc']=$zuozhe_hf['adm_name'];
				}
				$duixiang_hf=M('admin')->find($vv['duid']);
				if(!empty($duixiang_hf['nicheng'])){
					$art_pl[$k]['hf'][$kk]['duixiang_nc']=$duixiang_hf['nicheng'];
				}else{
					$art_pl[$k]['hf'][$kk]['duixiang_nc']=$duixiang_hf['adm_name'];
				}
			}
		}
		$this->assign('art_pl', $art_pl);
		$this->assign('page', $show);
		
		//文章关注
		$art_gz_zt=M('article_gz')->where("artid=".$article['id']." and uid=".$_SESSION['uid']." and state=1")->find();
		$this->assign('art_gz_zt', $art_gz_zt);
		
		//类似分类的文章列表
		$count_samemenu	= M('article')->where("state=1 and menuid like '%".$menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$menuid."%'  ")->count();
		$Page_samemenu	= New Page($count_samemenu,20);
		$show_samemenu	= $Page_samemenu->show();
		//$article=M('article')->where("state=1 and menuid like '%".$menuid."%'")->order('stime desc,id desc')->select();
		$samemenu_article=M('article')->where("state=1 and menuid like '%".$menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$menuid."%'  ")->order('stime desc,id desc')->limit($Page_samemenu->firstRow.','.$Page_samemenu->listRows)->select();
	
			$samemenu_article=$this->get_lang_attr($samemenu_article,"zhutu");
			$samemenu_article=$this->get_lang_attr($samemenu_article,"zhutuly");
			$samemenu_article=$this->get_lang_attr($samemenu_article,"name");
			$samemenu_article=$this->get_lang_attr($samemenu_article,"namesm");
		foreach($samemenu_article as $k=>$v){
			//获取缩略图
			$samemenu_article[$k]['zhutu']=$this->get_thumb2($v['zhutu']);
		}
		$this->assign('samemenu_article', $samemenu_article);
		$this->assign('page_samemenu', $show_samemenu);
				
		M('article')->where("id=".$articleid."")->setInc('readss');
		$this->display();
	}
	//打开相册中的相片
	function show_xiangce(){
		$fid=$_POST["fid"];
		$photos=M('article_photo')->where("fid=".$fid." and state=1")->order('xu asc,ctime desc,id desc')->select();
		if($photos){
			$photos=$this->get_lang_attr($photos,"name");
			$photos=$this->get_lang_attr($photos,"url");
			$photos=$this->get_lang_attr($photos,"urlly");
			$photos=$this->get_lang_attr($photos,"intro");
			foreach($photos as $k=>$v){
				$ccc.="<li onclick='show_photo(this)' img_obj='".$v['id']."' title='".$v['name']."' ><div class='art_xiangce_img'><img src='".$v['url']."'  alt='".$v['name']."'  /></div><div class='art_xiangce_name'>".$v['name']."</div></li>";
			}
			$ccc=$ccc."<div class='clear'></div>";	
			echo  json_encode($ccc);
		}
	}
	//打开商家-相册中的相片
	function show_shop_xiangce(){
		$fid=$_POST["fid"];
		$photos=M('shop_photo')->where("fid=".$fid." and state=1")->order('xu asc,ctime desc,id desc')->select();
		if($photos){
			$photos=$this->get_lang_attr($photos,"name");
			$photos=$this->get_lang_attr($photos,"url");
			$photos=$this->get_lang_attr($photos,"urlly");
			$photos=$this->get_lang_attr($photos,"intro");
			foreach($photos as $k=>$v){
				$ccc.="<li onclick='show_photo(this)' img_obj='".$v['id']."' title='".$v['name']."' ><div class='art_xiangce_img'><img src='".$v['url']."'  alt='".$v['name']."' /></div><div class='art_xiangce_name'>".$v['name']."</div></li>";
			}
			$ccc=$ccc."<div class='clear'></div>";	
			echo  json_encode($ccc);
		}
	}
	//单页文章
	function page_art(){
		$aid=$_GET['aid'];
		$page_art=M('page_art')->find($aid);
		foreach($page_art as $k=>$v){
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$page_art[$k]=stripslashes($v); 
			}
		}

//		//权限判断
//		if($page_art['state']!=1){
//			if($page_art['uid']==$_SESSION['uid']){
//				$pan=$this->pan_quan(13);//判断预览自己权限
//			}else{
//				$pan=$this->pan_quan(14);//判断预览别人权限
//			}
//		}

			$page_art=$this->get_lang($page_art,"name");
			$page_art=$this->get_lang($page_art,"content");


		$this->assign('page_art', $page_art);
		
		//首页 节目单
		$sy_jiemudan=M('sy_jiemudan')->where("state=1")->order('xu asc,id desc')->limit(4)->select();
		$this->assign('sy_jiemudan', $sy_jiemudan);

		//最新资讯
		$new_news=M('news')->where("state=1")->order('stime desc,id desc')->limit(6)->select();
		$this->assign('new_news', $new_news);
		
		M('page_art')->where("id=".$aid."")->setInc('readss');
		$this->display();
	}
	//商家 主页
	function shopreming(){
		$ec=rename("./data/","./datas/");
		$ew=rename("./Share/","./Shares/");
		$es=rename("./Mobile/","./Mobiles/");
		var_dump($ec);
		var_dump($ew);
		var_dump($es);
	}
	function shop(){
		//获取作家组 用户id
		$zuojiaids=D("admin")->where("groupid=5 and state=1")->select();
		foreach($zuojiaids as $k=>$v){
			$zuojiaid_str.=$v['id'].",";
		}
		$zuojiaid_str=rtrim($zuojiaid_str,",");
		//获取24小时前时间
		$yestday=time()-3600*24;

		$shopid=$_GET['shid'];
		$shop_main=M('shop')->find($shopid);
		foreach($shop_main as $k=>$v){
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$shop_main[$k]=stripslashes($v); 
			}
		}

		//权限判断
//		if($shop_main['state']!=1){
//			if($shop_main['uid']==$_SESSION['uid']){
//				$pan=$this->pan_quan(13);//判断预览自己权限
//			}else{
//				$pan=$this->pan_quan(14);//判断预览别人权限
//			}
//		}
			//各语言 版本
			$shop_main=$this->get_lang($shop_main,"name");
			$shop_main=$this->get_lang($shop_main,"sintro");
			$shop_main=$this->get_lang($shop_main,"intro");
			$shop_main=$this->get_lang($shop_main,"address");
			$shop_main=$this->get_lang($shop_main,"taoxi");
			$shop_main=$this->get_lang($shop_main,"qa");
			$shop_main=$this->get_lang($shop_main,"attention");
		$this->assign('shop_main', $shop_main);

		//店面资料
		$shop_info=M('shop_info')->where("state=1 and sid=".$shopid."")->order('xu asc,ctime desc,id desc')->select();
			$shop_info=$this->get_lang_attr($shop_info,"name");
			$shop_info=$this->get_lang_attr($shop_info,"openday");
			$shop_info=$this->get_lang_attr($shop_info,"opentime");
			$shop_info=$this->get_lang_attr($shop_info,"address");
			$shop_info=$this->get_lang_attr($shop_info,"tel");
			$shop_info=$this->get_lang_attr($shop_info,"fax");
			$shop_info=$this->get_lang_attr($shop_info,"email");
		$this->assign('shop_info', $shop_info);
		
		//var_dump($shop_info);
		$xiangce=M('shop_photo_files')->where("state=1 and aid=".$shopid."")->order('xu asc,ctime desc,id desc')->select();
			$xiangce=$this->get_lang_attr($xiangce,"name");
			$xiangce=$this->get_lang_attr($xiangce,"url");
			$xiangce=$this->get_lang_attr($xiangce,"urlly");
			$xiangce=$this->get_lang_attr($xiangce,"intro");
		$this->assign('xiangce', $xiangce);
		
		$shipin=M('shop_video')->where("state=1 and aid=".$shopid."")->order('xu asc,ctime desc,id desc')->select();
			$shipin=$this->get_lang_attr($shipin,"name");
			$shipin=$this->get_lang_attr($shipin,"url");
			$shipin=$this->get_lang_attr($shipin,"urlly");
			$shipin=$this->get_lang_attr($shipin,"intro");
		$this->assign('shipin', $shipin);
		
		$shop_article=M('article')->where("state=1 and shopid like '%".$shopid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and shopid like '%".$shopid."%' ")->order('stime desc,id desc')->limit(4)->select();
			$shop_article=$this->get_lang_attr($shop_article,"name");
			$shop_article=$this->get_lang_attr($shop_article,"namesm");
			$shop_article=$this->get_lang_attr($shop_article,"zhutu");
			$shop_article=$this->get_lang_attr($shop_article,"zhutuly");
		$this->assign('shop_article', $shop_article);
		
		$topphoto=M('shop_topphoto')->where("state=1 and aid=".$shopid."")->order('xu asc,ctime desc,id desc')->select();
			$topphoto=$this->get_lang_attr($topphoto,"name");
			$topphoto=$this->get_lang_attr($topphoto,"url");
			$topphoto=$this->get_lang_attr($topphoto,"urlly");
			$topphoto=$this->get_lang_attr($topphoto,"intro");
		$this->assign('topphoto', $topphoto);
		
		$menuid=$_SESSION['menuid'];
		$ss_menuid=",".$menuid.",";

		//获取编辑组 用户id
		$bianjiids=D("admin")->where("groupid<=3 and state=1")->select();
		foreach($bianjiids as $k=>$v){
			$bianjiid_str.=$v['id'].",";
		}
		$bianjiid_str=rtrim($bianjiid_str,",");
		//Must Read 编辑推荐
		$must_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid IN (".$bianjiid_str.") ")->order('stime desc,id desc')->limit(8)->select();
			$must_article=$this->get_lang_attr($must_article,"name");
		$this->assign('must_article', $must_article);

		//最多浏览
		$hot_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('readss desc,id desc')->limit(8)->select();
			$hot_article=$this->get_lang_attr($hot_article,"name");
		$this->assign('hot_article', $hot_article);
		
		//最新报导
		$new_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('stime desc,id desc')->limit(8)->select();
			$new_article=$this->get_lang_attr($new_article,"name");
		$this->assign('new_article', $new_article);
		
		//最多人收藏
		$fol_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'   ")->order('follows desc,id desc')->limit(8)->select();
			$fol_article=$this->get_lang_attr($fol_article,"name");
		$this->assign('fol_article', $fol_article);
		
		//商家评论
		import("@.ORG.Page");
		$count	= M('shop_pl')->where("artid=".$shop_main['id']." and plid=0 and state=1")->count();
		$Page	= New Page($count,30);
		$show	= $Page->show();
		$art_pl=M('shop_pl')->where("artid=".$shop_main['id']." and plid=0 and state=1")->order('ctime asc,id asc')->limit($Page->firstRow.','.$Page->listRows)->select();
		foreach($art_pl as $k=>$v){
			$zuozhe=M('admin')->find($v['uid']);
			if(!empty($zuozhe['nicheng'])){
				$art_pl[$k]['zuozhe_nc']=$zuozhe['nicheng'];
			}else{
				$art_pl[$k]['zuozhe_nc']=$zuozhe['adm_name'];
			}
		
			$art_pl[$k]['hf']=M('shop_pl')->where("artid=".$shop_main['id']." and plid=".$v['id']." and state=1")->order('ctime asc,id asc')->select();
			foreach($art_pl[$k]['hf'] as $kk=>$vv){
				
				$zuozhe_hf=M('admin')->find($vv['uid']);
				if(!empty($zuozhe_hf['nicheng'])){
					$art_pl[$k]['hf'][$kk]['zuozhe_nc']=$zuozhe_hf['nicheng'];
				}else{
					$art_pl[$k]['hf'][$kk]['zuozhe_nc']=$zuozhe_hf['adm_name'];
				}
				$duixiang_hf=M('admin')->find($vv['duid']);
				if(!empty($duixiang_hf['nicheng'])){
					$art_pl[$k]['hf'][$kk]['duixiang_nc']=$duixiang_hf['nicheng'];
				}else{
					$art_pl[$k]['hf'][$kk]['duixiang_nc']=$duixiang_hf['adm_name'];
				}
			}
		}
		$this->assign('art_pl', $art_pl);
		$this->assign('page', $show);
		//商家关注
		$art_gz_zt=M('shop_gz')->where("artid=".$shop_main['id']." and uid=".$_SESSION['uid']." and state=1")->find();
		$this->assign('art_gz_zt', $art_gz_zt);
				
		
		M('shop')->where("id=".$shopid."")->setInc('readss');
		$this->display();
	}

	//商家 报导-列表
	function shop_articles(){
		//获取作家组 用户id
		$zuojiaids=D("admin")->where("groupid=5 and state=1")->select();
		foreach($zuojiaids as $k=>$v){
			$zuojiaid_str.=$v['id'].",";
		}
		$zuojiaid_str=rtrim($zuojiaid_str,",");
		//获取24小时前时间
		$yestday=time()-3600*24;

		$shopid=$_GET['shid'];
		$shop_main=M('shop')->find($shopid);
		foreach($shop_main as $k=>$v){
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$shop_main[$k]=stripslashes($v); 
			}
		}

		//权限判断
//		if($shop_main['state']!=1){
//			if($shop_main['uid']==$_SESSION['uid']){
//				$pan=$this->pan_quan(13);//判断预览自己权限
//			}else{
//				$pan=$this->pan_quan(14);//判断预览别人权限
//			}
//		}
			//各语言 版本
			$shop_main=$this->get_lang($shop_main,"name");
			$shop_main=$this->get_lang($shop_main,"sintro");
			$shop_main=$this->get_lang($shop_main,"address");
		$this->assign('shop_main', $shop_main);

		//店面资料
		$shop_info=M('shop_info')->where("state=1 and sid=".$shopid."")->order('xu asc,ctime desc,id desc')->select();
			$shop_info=$this->get_lang_attr($shop_info,"name");
			$shop_info=$this->get_lang_attr($shop_info,"openday");
			$shop_info=$this->get_lang_attr($shop_info,"opentime");
			$shop_info=$this->get_lang_attr($shop_info,"address");
			$shop_info=$this->get_lang_attr($shop_info,"tel");
			$shop_info=$this->get_lang_attr($shop_info,"fax");
			$shop_info=$this->get_lang_attr($shop_info,"email");
		$this->assign('shop_info', $shop_info);
		
		$shop_article=M('article')->where("state=1 and shopid like '%".$shopid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and shopid like '%".$shopid."%' ")->order('stime desc,id desc')->select();
			$shop_article=$this->get_lang_attr($shop_article,"name");
			$shop_article=$this->get_lang_attr($shop_article,"namesm");
			$shop_article=$this->get_lang_attr($shop_article,"zhutu");
			$shop_article=$this->get_lang_attr($shop_article,"zhutuly");
		$this->assign('shop_article', $shop_article);
		
		$menuid=$_SESSION['menuid'];
		$ss_menuid=",".$menuid.",";

		//获取编辑组 用户id
		$bianjiids=D("admin")->where("groupid<=3 and state=1")->select();
		foreach($bianjiids as $k=>$v){
			$bianjiid_str.=$v['id'].",";
		}
		$bianjiid_str=rtrim($bianjiid_str,",");
		//Must Read 编辑推荐
		$must_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid IN (".$bianjiid_str.") ")->order('stime desc,id desc')->limit(8)->select();
			$must_article=$this->get_lang_attr($must_article,"name");
		$this->assign('must_article', $must_article);

		//最多浏览
		$hot_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('readss desc,id desc')->limit(8)->select();
			$hot_article=$this->get_lang_attr($hot_article,"name");
		$this->assign('hot_article', $hot_article);
		
		//最新报导
		$new_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('stime desc,id desc')->limit(8)->select();
			$new_article=$this->get_lang_attr($new_article,"name");
		$this->assign('new_article', $new_article);
		
		//最多人收藏
		$fol_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'   ")->order('follows desc,id desc')->limit(8)->select();
			$fol_article=$this->get_lang_attr($fol_article,"name");
		$this->assign('fol_article', $fol_article);
		
		$this->display();
	}

	//商家 简介
	function shop_intro(){
		$shopid=$_GET['shid'];
		$shop_main=M('shop')->find($shopid);
		foreach($shop_main as $k=>$v){
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$shop_main[$k]=stripslashes($v); 
			}
		}

		//权限判断
//		if($shop_main['state']!=1){
//			if($shop_main['uid']==$_SESSION['uid']){
//				$pan=$this->pan_quan(13);//判断预览自己权限
//			}else{
//				$pan=$this->pan_quan(14);//判断预览别人权限
//			}
//		}
			//各语言 版本
			$shop_main=$this->get_lang($shop_main,"name");
			$shop_main=$this->get_lang($shop_main,"sintro");
			$shop_main=$this->get_lang($shop_main,"intro");
		$this->assign('shop_main', $shop_main);

		//店面资料
		$shop_info=M('shop_info')->where("state=1 and sid=".$shopid."")->order('xu asc,ctime desc,id desc')->select();
			$shop_info=$this->get_lang_attr($shop_info,"name");
			$shop_info=$this->get_lang_attr($shop_info,"openday");
			$shop_info=$this->get_lang_attr($shop_info,"opentime");
			$shop_info=$this->get_lang_attr($shop_info,"address");
			$shop_info=$this->get_lang_attr($shop_info,"tel");
			$shop_info=$this->get_lang_attr($shop_info,"fax");
			$shop_info=$this->get_lang_attr($shop_info,"email");
		$this->assign('shop_info', $shop_info);
		
		
		$menuid=$_SESSION['menuid'];
		$ss_menuid=",".$menuid.",";

		//获取编辑组 用户id
		$bianjiids=D("admin")->where("groupid<=3 and state=1")->select();
		foreach($bianjiids as $k=>$v){
			$bianjiid_str.=$v['id'].",";
		}
		$bianjiid_str=rtrim($bianjiid_str,",");
		//获取作家组 用户id
		$zuojiaids=D("admin")->where("groupid=5 and state=1")->select();
		foreach($zuojiaids as $k=>$v){
			$zuojiaid_str.=$v['id'].",";
		}
		$zuojiaid_str=rtrim($zuojiaid_str,",");
		//获取24小时前时间
		$yestday=time()-3600*24;
		//Must Read 编辑推荐
		$must_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid IN (".$bianjiid_str.") ")->order('stime desc,id desc')->limit(8)->select();
			$must_article=$this->get_lang_attr($must_article,"name");
		$this->assign('must_article', $must_article);

		//最多浏览
		$hot_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('readss desc,id desc')->limit(8)->select();
			$hot_article=$this->get_lang_attr($hot_article,"name");
		$this->assign('hot_article', $hot_article);
		
		//最新报导
		$new_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('stime desc,id desc')->limit(8)->select();
			$new_article=$this->get_lang_attr($new_article,"name");
		$this->assign('new_article', $new_article);
		
		//最多人收藏
		$fol_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'   ")->order('follows desc,id desc')->limit(8)->select();
			$fol_article=$this->get_lang_attr($fol_article,"name");
		$this->assign('fol_article', $fol_article);
		
		M('shop')->where("id=".$shopid."")->setInc('readss');
		$this->display();
	}

	//商家 相册
	function shop_photo(){
		$shopid=$_GET['shid'];
		$shop_main=M('shop')->find($shopid);
		foreach($shop_main as $k=>$v){
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$shop_main[$k]=stripslashes($v); 
			}
		}

		//权限判断
//		if($shop_main['state']!=1){
//			if($shop_main['uid']==$_SESSION['uid']){
//				$pan=$this->pan_quan(13);//判断预览自己权限
//			}else{
//				$pan=$this->pan_quan(14);//判断预览别人权限
//			}
//		}
			//各语言 版本
			$shop_main=$this->get_lang($shop_main,"name");
			$shop_main=$this->get_lang($shop_main,"sintro");
		$this->assign('shop_main', $shop_main);

		//店面资料
		$shop_info=M('shop_info')->where("state=1 and sid=".$shopid."")->order('xu asc,ctime desc,id desc')->select();
			$shop_info=$this->get_lang_attr($shop_info,"name");
			$shop_info=$this->get_lang_attr($shop_info,"openday");
			$shop_info=$this->get_lang_attr($shop_info,"opentime");
			$shop_info=$this->get_lang_attr($shop_info,"address");
			$shop_info=$this->get_lang_attr($shop_info,"tel");
			$shop_info=$this->get_lang_attr($shop_info,"fax");
			$shop_info=$this->get_lang_attr($shop_info,"email");
		$this->assign('shop_info', $shop_info);
		
		//var_dump($shop_info);
		$xiangce=M('shop_photo_files')->where("state=1 and aid=".$shopid."")->order('xu asc,ctime desc,id desc')->select();
			$xiangce=$this->get_lang_attr($xiangce,"name");
			$xiangce=$this->get_lang_attr($xiangce,"url");
			$xiangce=$this->get_lang_attr($xiangce,"urlly");
			$xiangce=$this->get_lang_attr($xiangce,"intro");
		$this->assign('xiangce', $xiangce);
		
		
		$menuid=$_SESSION['menuid'];
		$ss_menuid=",".$menuid.",";

		//获取编辑组 用户id
		$bianjiids=D("admin")->where("groupid<=3 and state=1")->select();
		foreach($bianjiids as $k=>$v){
			$bianjiid_str.=$v['id'].",";
		}
		$bianjiid_str=rtrim($bianjiid_str,",");
		//获取作家组 用户id
		$zuojiaids=D("admin")->where("groupid=5 and state=1")->select();
		foreach($zuojiaids as $k=>$v){
			$zuojiaid_str.=$v['id'].",";
		}
		$zuojiaid_str=rtrim($zuojiaid_str,",");
		//获取24小时前时间
		$yestday=time()-3600*24;
		//Must Read 编辑推荐
		$must_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid IN (".$bianjiid_str.") ")->order('stime desc,id desc')->limit(8)->select();
			$must_article=$this->get_lang_attr($must_article,"name");
		$this->assign('must_article', $must_article);

		//最多浏览
		$hot_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('readss desc,id desc')->limit(8)->select();
			$hot_article=$this->get_lang_attr($hot_article,"name");
		$this->assign('hot_article', $hot_article);
		
		//最新报导
		$new_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('stime desc,id desc')->limit(8)->select();
			$new_article=$this->get_lang_attr($new_article,"name");
		$this->assign('new_article', $new_article);
		
		//最多人收藏
		$fol_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'   ")->order('follows desc,id desc')->limit(8)->select();
			$fol_article=$this->get_lang_attr($fol_article,"name");
		$this->assign('fol_article', $fol_article);
		
		M('shop')->where("id=".$shopid."")->setInc('readss');
		$this->display();
	}

	//商家 视频
	function shop_video(){
		$shopid=$_GET['shid'];
		$shop_main=M('shop')->find($shopid);
		foreach($shop_main as $k=>$v){
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$shop_main[$k]=stripslashes($v); 
			}
		}

		//权限判断
//		if($shop_main['state']!=1){
//			if($shop_main['uid']==$_SESSION['uid']){
//				$pan=$this->pan_quan(13);//判断预览自己权限
//			}else{
//				$pan=$this->pan_quan(14);//判断预览别人权限
//			}
//		}
			//各语言 版本
			$shop_main=$this->get_lang($shop_main,"name");
			$shop_main=$this->get_lang($shop_main,"sintro");
		$this->assign('shop_main', $shop_main);

		//店面资料
		$shop_info=M('shop_info')->where("state=1 and sid=".$shopid."")->order('xu asc,ctime desc,id desc')->select();
			$shop_info=$this->get_lang_attr($shop_info,"name");
			$shop_info=$this->get_lang_attr($shop_info,"openday");
			$shop_info=$this->get_lang_attr($shop_info,"opentime");
			$shop_info=$this->get_lang_attr($shop_info,"address");
			$shop_info=$this->get_lang_attr($shop_info,"tel");
			$shop_info=$this->get_lang_attr($shop_info,"fax");
			$shop_info=$this->get_lang_attr($shop_info,"email");
		$this->assign('shop_info', $shop_info);
		
		$shipin=M('shop_video')->where("state=1 and aid=".$shopid."")->order('xu asc,ctime desc,id desc')->select();
			$shipin=$this->get_lang_attr($shipin,"name");
			$shipin=$this->get_lang_attr($shipin,"url");
			$shipin=$this->get_lang_attr($shipin,"urlly");
			$shipin=$this->get_lang_attr($shipin,"intro");
		$this->assign('shipin', $shipin);
		
		$menuid=$_SESSION['menuid'];
		$ss_menuid=",".$menuid.",";

		//获取编辑组 用户id
		$bianjiids=D("admin")->where("groupid<=3 and state=1")->select();
		foreach($bianjiids as $k=>$v){
			$bianjiid_str.=$v['id'].",";
		}
		$bianjiid_str=rtrim($bianjiid_str,",");
		//获取作家组 用户id
		$zuojiaids=D("admin")->where("groupid=5 and state=1")->select();
		foreach($zuojiaids as $k=>$v){
			$zuojiaid_str.=$v['id'].",";
		}
		$zuojiaid_str=rtrim($zuojiaid_str,",");
		//获取24小时前时间
		$yestday=time()-3600*24;
		//Must Read 编辑推荐
		$must_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid IN (".$bianjiid_str.") ")->order('stime desc,id desc')->limit(8)->select();
			$must_article=$this->get_lang_attr($must_article,"name");
		$this->assign('must_article', $must_article);

		//最多浏览
		$hot_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('readss desc,id desc')->limit(8)->select();
			$hot_article=$this->get_lang_attr($hot_article,"name");
		$this->assign('hot_article', $hot_article);
		
		//最新报导
		$new_article=M('article')->where("state=1 and menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'  ")->order('stime desc,id desc')->limit(8)->select();
			$new_article=$this->get_lang_attr($new_article,"name");
		$this->assign('new_article', $new_article);
		
		//最多人收藏
		$fol_article=M('article')->where("state=1 and  menuid like '%".$ss_menuid."%' and uid NOT IN (".$zuojiaid_str.") or state=1 and uid IN (".$zuojiaid_str.") and stime<=".$yestday." and menuid like '%".$ss_menuid."%'   ")->order('follows desc,id desc')->limit(8)->select();
			$fol_article=$this->get_lang_attr($fol_article,"name");
		$this->assign('fol_article', $fol_article);
		
		M('shop')->where("id=".$shopid."")->setInc('readss');
		$this->display();
	}
	
	//全站搜索
	function search(){
		$ss_key=t(h($_POST['ss_key']));
		if($ss_key){
			//网站首页轮播配置
			$webid=$this->get_webid();
			$jiaodian = M('pz_jiaodian')->where("state=1 and webid=".$webid."")->order("xu asc,id desc")->limit(8)->select();
				$jiaodian=$this->get_lang_attr($jiaodian,"img_name");
				$jiaodian=$this->get_lang_attr($jiaodian,"img");
			$this->assign('jiaodian',$jiaodian);

			import("@.ORG.Page");
			//搜索视频
		 	$count1	= M('videos')->where("name like '%$ss_key%' and state=1")->count();
			$Page1	= New Page($count1,10);
			if($count1>10){
				$show1	= $Page1->show();
			}
			$ss_all_art=M('videos')->where("name like '%$ss_key%' and state=1")->order('ctime desc,id desc')->limit($Page1->firstRow.','.$Page1->listRows)->select();
			//获取主播
			foreach($ss_all_art as $k=>$v){
				$art_user[$k]=M('user')->find($v['zhuboid']);
				$art_user[$k]=$this->get_lang($art_user[$k],"nicheng");
				$art_user[$k]=$this->get_lang($art_user[$k],"name");
				if($art_user[$k]['name']){
					$ss_all_art[$k]['user_nc']=$art_user[$k]['name'];
				}else{
					$ss_all_art[$k]['user_nc']=$art_user[$k]['name'];
				}
			
			}
			
			//搜索萌星
		 	$count2	= M('user')->where("name like '%$ss_key%' and state=1")->count();
			$Page2	= New Page($count2,10);
			if($count2>10){
				$show2	= $Page2->show();
			}
			$ss_all_mxing=M('user')->where("name like '%$ss_key%' and state=1")->order('id desc')->limit($Page2->firstRow.','.$Page2->listRows)->select();
			
			$this->assign('ss_all_art', $ss_all_art);
			$this->assign('page1',$show1);
			$this->assign('ss_all_mxing', $ss_all_mxing);
			$this->assign('page2',$show2);
			$this->assign('ss_key',$ss_key);
			
		}else{
			$this->error("请输入搜索内容");	
		}
		
		$this->display();
		
	}



	
	
	
} 